// 首页
// http://mss.playpayplay.com:44558/

// 登录
// http://mss.playpayplay.com:44558/#/pages/login/login

// 接单
// http://mss.playpayplay.com:44558/shokey/shokey/takeOrder/win


let token = Android.getMap("token")
localStorage.setItem("token", token)


function getAndroidToken() {
    let token = localStorage.getItem("token").replace(/^"|"$/g, '');
    return token
}
getAndroidToken()



// 接单
function getParameterHandler() {
    let token = parameter.getMap("token")
    let headers = {
        "Authorization": "Bearer " + token
    }
    let body = {}
    let strUrl = ``
    let url = parameter.getMap("url") + strUrl
    return {
        mediaType: "json",
        requestType: "GET",
        url: url,
        headers: JSON.stringify(headers),
        body: JSON.stringify(body)
    }
}
getParameterHandler()


// 处理返回数据
function getResponse() {
    let res = response.getMap("res")
    res = JSON.parse(res)

    let code = "500"
    let message = "接单中"

    if (res["code"] == 200 && res["data"]["code"] != "fail") {
        code = "200"
        message = res["data"]["detail"]
    } else if (res["code"] == 200 && res["data"]["code"] == "fail") {
        code = "500"
        message = res["data"]["detail"]
    } else {
        code = "300"
        message = res["message"]
    }

    return {
        code: code,
        message: message,
        dataKey: "",
        dataValue: ""
    }
}
getResponse()


// {
// 	"success": true,
// 	"code": 200,
// 	"message": "请求成功",
// 	"data": {
// 		"code": "fail",
// 		"detail": "暂无可接任务, 请稍后再试"
// 	}
// }